package com.ruoyi.system.service.impl;
import com.ruoyi.system.entity.InspectionPlanTaskDetailsFile;
import com.ruoyi.system.mapper.InspectionPlanTaskDetailsFileMapper;
import com.ruoyi.system.service.InspectionPlanTaskDetailsFileService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

/**
 * 计划任务详情表_附件ID(InspectionPlanTaskDetailsFile)表服务实现类
 * @since 2023-04-17 15:04:56
 */
@Service("inspectionPlanTaskDetailsFileService")
public class InspectionPlanTaskDetailsFileServiceImpl implements InspectionPlanTaskDetailsFileService {
    @Resource
    private InspectionPlanTaskDetailsFileMapper inspectionPlanTaskDetailsFileMapper;

    /**
     * 通过ID查询单条数据
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public InspectionPlanTaskDetailsFile queryById(Integer id) {
        return this.inspectionPlanTaskDetailsFileMapper.queryById(id);
    }

    /**
     * 分页查询
     * @param inspectionPlanTaskDetailsFile 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<InspectionPlanTaskDetailsFile> queryByPage(InspectionPlanTaskDetailsFile inspectionPlanTaskDetailsFile, PageRequest pageRequest) {
        long total = this.inspectionPlanTaskDetailsFileMapper.count(inspectionPlanTaskDetailsFile);
        return new PageImpl<>(this.inspectionPlanTaskDetailsFileMapper.queryAllByLimit(inspectionPlanTaskDetailsFile, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     * @param inspectionPlanTaskDetailsFile 实例对象
     * @return 实例对象
     */
    @Override
    public InspectionPlanTaskDetailsFile insert(InspectionPlanTaskDetailsFile inspectionPlanTaskDetailsFile) {
        this.inspectionPlanTaskDetailsFileMapper.insert(inspectionPlanTaskDetailsFile);
        return inspectionPlanTaskDetailsFile;
    }

    /**
     * 修改数据
     * @param inspectionPlanTaskDetailsFile 实例对象
     * @return 实例对象
     */
    @Override
    public InspectionPlanTaskDetailsFile update(InspectionPlanTaskDetailsFile inspectionPlanTaskDetailsFile) {
        this.inspectionPlanTaskDetailsFileMapper.update(inspectionPlanTaskDetailsFile);
        return this.queryById(inspectionPlanTaskDetailsFile.getId());
    }

    /**
     * 通过主键删除数据
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.inspectionPlanTaskDetailsFileMapper.deleteById(id) > 0;
    }
}
